package com.crm.service.impl.verifyPhone;

import com.crm.dao.mapper.customMapper.verifyPhoneCustomMapper.VerifyPhoneCustomMapper;
import com.crm.dao.mapper.verifyPhone.VerifyPhoneMapper;
import com.crm.model.entity.verifyPhone.VerifyPhone;
import com.crm.model.qo.verifyPhone.VerifyPhoneQO;
import com.crm.model.qo.verifyPhone.VerifyPhoneReportQO;
import com.crm.model.vo.verifyPhone.VerifyPhoneReportVO;
import com.crm.model.vo.verifyPhone.VerifyPhoneVO;
import com.crm.service.verifyPhone.VerifyPhoneDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Author renshaorong
 * @Date 2021/07/07 2:05 下午
 */
@Service
public class VerifyPhoneDbServiceImpl implements VerifyPhoneDbService {

    @Autowired
    private VerifyPhoneCustomMapper verifyPhoneCustomMapper;

    @Autowired
    private VerifyPhoneMapper verifyPhoneMapper;

    /**
     * 获取列表
     * @param verifyPhoneQO
     * @param toString
     * @return
     */
    @Override
    public List<VerifyPhoneVO> selectAllVerifyPhoneList(VerifyPhoneQO verifyPhoneQO, String toString){
        return verifyPhoneCustomMapper.selectAllVerifyPhoneList(verifyPhoneQO,toString);
    }

    /**
     * 修改（字段为空时不修改）
     * @param verifyPhone
     * @return
     */
    @Override
    public boolean updateByPrimaryKeySelective(VerifyPhone verifyPhone) {
        return verifyPhoneMapper.updateByPrimaryKeySelective(verifyPhone) > 0;
    }

    @Override
    public VerifyPhone selectVerifyPhoneById(String verifyPhoneId) {
        return verifyPhoneMapper.selectByPrimaryKey(verifyPhoneId);
    }

    /**
     * 新增核实电话
     * @Author pym
     * @Date  2021/7/9 10:58
     * @param verifyPhone 核实电话
     * @return {@link {java.lang.Boolean}}
     */
    @Override
    public Boolean insertVerifyPhone(VerifyPhone verifyPhone) {
        Boolean result = false;
        int num = verifyPhoneMapper.insert(verifyPhone);
        if (num > 0) {
            result = true;
        }
        return result;
    }


    /**
     * @Description: 电话核实报表
     * @Param: [reportQO]
     * @Return: java.util.List<com.crm.model.vo.verifyPhone.VerifyPhoneReportVO>
     * @Author: lixq-f
     * @Date: 2021/7/13
     **/
    @Override
    public List<VerifyPhoneReportVO> getLe30VerifyPhoneReport(VerifyPhoneReportQO reportQO) {
        return verifyPhoneCustomMapper.getLe30VerifyPhoneReport(reportQO);
    }


    /**
     * @Description: 电话核实报表
     * @Param: [reportQO]
     * @Return: java.util.List<com.crm.model.vo.verifyPhone.VerifyPhoneReportVO>
     * @Author renshaorong
     * @Date 2021/8/3
     **/
    @Override
    public List<VerifyPhoneReportVO> getGe30Lt60VerifyPhoneReport(VerifyPhoneReportQO reportQO) {
        return verifyPhoneCustomMapper.getGe30Lt60VerifyPhoneReport(reportQO);
    }

    /**
     * @Description: 电话核实报表
     * @Param: [reportQO]
     * @Return: java.util.List<com.crm.model.vo.verifyPhone.VerifyPhoneReportVO>
     * @Author: lixq-f
     * @Date: 2021/7/13
     **/
    @Override
    public List<VerifyPhoneReportVO> getGe60Lt90VerifyPhoneReport(VerifyPhoneReportQO reportQO) {
        return verifyPhoneCustomMapper.getGe60Lt90VerifyPhoneReport(reportQO);
    }


    /**
     * @Description: 电话核实报表
     * @Param: [reportQO]
     * @Return: java.util.List<com.crm.model.vo.verifyPhone.VerifyPhoneReportVO>
     * @Author: lixq-f
     * @Date: 2021/7/13
     **/
    @Override
    public List<VerifyPhoneReportVO> getGe90VerifyPhoneReport(VerifyPhoneReportQO reportQO) {
        return verifyPhoneCustomMapper.getGe90VerifyPhoneReport(reportQO);
    }

    /**
     * 核实电话 管理端表格数据，返回分公司下个人 <30 <60 <90 >90 总时长数据
     * @param dateUnit
     * @param companyId
     * @return
     */
    @Override
    public List<VerifyPhoneReportVO> getDurationByCompanyId(Integer dateUnit, String companyId){
        return verifyPhoneCustomMapper.getDurationByCompanyId(dateUnit,companyId);
    }

    /**
     * 核实电话 超管端表格数据，返回各分公司下 <30 <60 <90 >90 总时长数据 平均数
     * @param dateUnit
     * @return
     */
    @Override
    public List<Map<String,Object>> getAllDurationGroupByCompanyId(Integer dateUnit){
        return verifyPhoneCustomMapper.getAllDurationGroupByCompanyId(dateUnit);
    }


}
